//
//  MyTableViewCell.m
//  Lmm_IOS
//
//  Created by 张哲炜 on 2018/9/20.
//  Copyright © 2018年 lmm. All rights reserved.
//

#import "MyTableViewCell.h"

@implementation MyTableViewCell{
    
    UIImageView *iconImageView;
    UILabel *descLabel;
    UILabel *descLabelRight;
    UIImageView *goViewIcon;
    UIView * divideArea;
    UIView *area1DivideLineBottom;
    int divideAreaHeight;
   // int leftMargin;
    
}


- (void) drawView:(int)row {
    
    if (row == 0) {
        self->iconImageView.image = [UIImage imageNamed:@"icon_my_order"];
        self->descLabel.text = @"我的订单";
    }else if (row == 1) {
        self->iconImageView.image = [UIImage imageNamed:@"icon_my_comment"];
        self->descLabel.text = @"我的评论";
    } else if (row == 2) {
        self->iconImageView.image = [UIImage imageNamed:@"icon_my_point"];
        self->descLabel.text = @"积分规则";
    } else if (row == 3) {
        self->iconImageView.image = [UIImage imageNamed:@"icon_my_about"];
        self->descLabel.text = @"关于我们";
    } else if (row == 4) {
        self->iconImageView.image = [UIImage imageNamed:@"icon_my_feedback"];
        self->descLabel.text = @"意见反馈";
    } else if (row == 5) {
        self->iconImageView.image = [UIImage imageNamed:@"icon_my_version"];
        self->descLabel.text = [NSString stringWithFormat:@"当前版本 %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
    }
    
    
    
//    if (row == 1 || row == 3 || row == 5) {
//        self->divideAreaHeight = 0;
//    } else {
//        self->divideAreaHeight = 10;
//    }
    
    if (row == 0) {
        self->descLabelRight.hidden = NO;
    } else {
        self->descLabelRight.hidden = YES;
    }
    
    if (row == 6) {
        self->goViewIcon.hidden = YES;
    } else {
        self->goViewIcon.hidden = NO;
    }
    
//    if (row == 0 || row == 2 || row == 4 || row == 5) {
//        self->leftMargin = 15;
//    } else {
//        self->leftMargin = 0;
//    }
}


-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        
        self->divideArea = UIView.new;
        self->divideArea.backgroundColor = UIColorFromRGB(0xEEEEEE);
        [self addSubview:self->divideArea];
        
        [self->divideArea makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.top).offset(0);
            make.left.equalTo(self.left).offset(0);
            make.right.equalTo(self.right).offset(0);
            make.height.equalTo(0);
        }];
        
        
        self->iconImageView = UIImageView.new;
        [self addSubview:self->iconImageView];
        
        [self->iconImageView makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self->divideArea.bottom).offset(15);
            make.left.equalTo(self.left).offset(15);
            make.width.equalTo(32);
            make.height.equalTo(32);
        }];
        
        self->descLabel = UILabel.new;
        self->descLabel.font = [UIFont systemFontOfSize:17];
        self->descLabel.textColor = UIColorFromRGB(0x514647);
        [self addSubview:self->descLabel];
        
        [self->descLabel makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self->iconImageView.centerY);
            make.left.equalTo(self->iconImageView.right).offset(15);
        }];
        
        self->goViewIcon = UIImageView.new;
        self->goViewIcon.image = [UIImage imageNamed:@"go"];
        [self addSubview:self->goViewIcon];
        
        [self->goViewIcon makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.right).offset(-10);
            make.centerY.equalTo(self->iconImageView.centerY);
            make.width.equalTo(10);
            make.height.equalTo(18.5);
        }];
        
        self->descLabelRight = UILabel.new;
        self->descLabelRight.text = @"查看全部订单";
        self->descLabelRight.font = [UIFont systemFontOfSize:15];
        self->descLabelRight.textColor = UIColorFromRGB(0x999999);
        [self addSubview:self->descLabelRight];
        
        [self->descLabelRight makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self->iconImageView.centerY);
            make.right.equalTo(self->goViewIcon.left).offset(-10);
        }];
        
        UIView *area1DivideLineTop = UIView.new;
        area1DivideLineTop.backgroundColor = UIColorFromRGB(0xF2F2F2);
        [self addSubview:area1DivideLineTop];
        
        [area1DivideLineTop makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.left).offset(0);
            make.right.equalTo(self.right).offset(15);
            make.bottom.equalTo(self->divideArea.bottom);
            make.height.equalTo(1/[[UIScreen mainScreen] scale]);
        }];
        
        
        self->area1DivideLineBottom = UIView.new;
        self->area1DivideLineBottom.backgroundColor = UIColorFromRGB(0xEEEEEE) ;
        [self addSubview:self->area1DivideLineBottom];
        
        [self->area1DivideLineBottom makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.bottom).offset(0);
            make.left.equalTo(self.left).offset(15);
            make.right.equalTo(self.right).offset(0);
            make.height.equalTo(1/[[UIScreen mainScreen] scale]);
        }];
        
      
    }
    return self;
}


- (void)awakeFromNib {
    
    [super awakeFromNib];
   
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

   
}

@end
